package com.itheima.mall.service.pms;

import cn.hutool.core.convert.Convert;
import com.itheima.mall.api.pms.BrandServiceApi;
import com.itheima.mall.dto.BrandDto;
import com.itheima.mall.pojo.pms.Brand;
import com.itheima.mall.vo.PageResult;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrandService {
    @DubboReference
    private BrandServiceApi brandServiceApi;

    /**
     * 添加品牌
     * @param brandDto
     */
    public void brandCreate(BrandDto brandDto) {
        brandServiceApi.brandCreate(brandDto);
    }

    /**
     * 删除品牌
     * @param id
     */
    public void deleteBrand(Integer id) {
        Long brandId = Convert.toLong(id);
        brandServiceApi.deleteBrand(brandId);

    }

    /**
     * 批量删除品牌
     * @param ids
     */
    public void deleteBatch(Integer[] ids) {
        brandServiceApi.deleteBatch(ids);
    }

    /**
     * 根据品牌名称分页获取品牌列表
     * @param pageNum
     * @param pageSize
     * @param keyword
     * @return
     */
    public PageResult brandList(Integer pageNum, Integer pageSize, String keyword) {
        PageResult result = brandServiceApi.brandList(pageNum,pageSize,keyword);
        return result;
    }

    /**
     * 获取全部品牌列表
     * @return
     */
    public List<Brand> brandListAll() {
        List<Brand> brandList = brandServiceApi.brandListAll();
        return brandList;
    }

    /**
     * 更新品牌
     * @param id
     * @param brandDto
     */
    public void update(Integer id, BrandDto brandDto) {
        brandServiceApi.update(id,brandDto);
    }


    /**
     * 根据编号查询品牌信息
     * @param id
     * @return
     */
    public Brand select(Integer id) {
        Long brandId = Convert.toLong(id);
        return brandServiceApi.select(brandId);

    }

    /**
     * 批量更新厂家制造商状态
     * @param ids
     * @param factoryStatus
     */
    public void updateFactoryStatus(Integer[] ids, Integer factoryStatus) {
        brandServiceApi.updateFactoryStatus(ids,factoryStatus);
    }

    /**
     * 批量更新显示状态
     * @param showStatus
     * @param ids
     * @return
     */
    public void updateShowStatus(Integer[] ids, Integer showStatus) {
        brandServiceApi.updateShowStatus(ids,showStatus);
    }
}
